using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter05
{
	/// <summary>
	/// Example07: One Block Pushes Another
	/// Two blocks of masses m_1 and m_2, with m_1 > m_2,
	/// are placed in contact with each other on a frictionless,
	/// horizontal surface. A constant horizontal force F is
	/// applied to m_1.
	/// (A) Find the magnitude of the acceleration of the system.
	/// (B) Determine the magnitude of the contact force between
	/// the two blocks.
	/// a_x = F/(m_1+m_2)
	/// F_2 = m_2/(m_1+m_2)*F
	/// </summary>
	public class Example07
	{
		public Example07()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Mass m1 = new L.Mass();
			m1.kg = 10.0;
			L.Mass m2 = new L.Mass();
			m2.kg = 20.0;
			L.Mass m = new L.Mass();
			m.kg = m1.kg + m2.kg;
			L.Force[] f = new L.Force[1];
			f[0] = new L.Force();
			f[0].X = 100.0;
			L.TotalForce F = new L.TotalForce(f);
			L.Acceleration a = new L.Acceleration(m,F);
			result += Convert.ToString(a.X);
			result += " "+Convert.ToString(F.X/(m1.kg+m2.kg));
			result += "\r\n";
			L.Force P = new L.Force(m2,a);
			result += Convert.ToString(P.X);
			result += " "+Convert.ToString(m2.kg*F.X/(m1.kg+m2.kg));
		}
	}
}
